package com.baizhi.pojo;

import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
@Scope(value = "singleton") //设置多例 或者单例
@Lazy  //懒加载
public class User {

    public User(){
        System.out.println("User被创建了");
    }

    @PostConstruct //注解初始化的方法
    public void init(){
        System.out.println("User被初始化了");
    }

    @PreDestroy //注解销毁的方法
    public void destory(){
        System.out.println("User被销毁了");
    }
}
